package com.example.mrzhou.srtfoodapplication;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Mr.Zhou on 2017/1/21.
 */

public class CategoryClassActivity extends BaseActivity{


    private List<Fresh> freshList = new ArrayList<Fresh>();

    public static void actionStart(Context context , String freshTitle , int Image1 , int Image2 ,int Image3 ){
        Intent intent = new Intent(context,CategoryClassActivity.class);
        intent.putExtra("fresh_title",freshTitle);
        intent.putExtra("image_1",Image1);
        intent.putExtra("image_2",Image2);
        intent.putExtra("image_3",Image3);
        context.startActivity(intent);

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.category_layout);

        String FreshTitle = getIntent().getStringExtra("fresh_title");//获取传入的标题
        int Image_1 = getIntent().getIntExtra("image_1",1);
        int Image_2 = getIntent().getIntExtra("image_2",2);
        int Image_3 = getIntent().getIntExtra("image_3",3);
        Fresh fresh1 = new Fresh();
        Fresh fresh2 = new Fresh();
        Fresh fresh3 = new Fresh();
        fresh1.setFreshImage(Image_1);
        fresh2.setFreshImage(Image_2);
        fresh3.setFreshImage(Image_3);
        freshList.add(fresh1);
        freshList.add(fresh2);
        freshList.add(fresh3);
        FreshClassAdapter adapter = new FreshClassAdapter(CategoryClassActivity.this,
                R.layout.fresh_class_item,freshList);
        ListView listView = (ListView) findViewById(R.id.list_view);
        listView.setAdapter(adapter);
        TextView textView = (TextView) findViewById(R.id.button_category_title);
        textView.setText(FreshTitle);
    }
}
